<!doctype html>
<html lang="zn">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>活动助手</title>
	<link rel="stylesheet" type="text/css" href="@res("/static/css/styles.css")">
</head>
<body>
<div class="wrapper">
	<div class="container">
		<h1>活动助手</h1>
		<form method="post" id="loginform" name="loginform" class="form js-partial-form" action="?">
			<input type="text" placeholder="账号" name="username" value="fork">
			<input type="password" placeholder="密码" name="password" value="123">
			<button class="js-json-post" type="submit" href="regeist.json" result="location.href='index.html'" id="regist-button">注册</button>
			<button class="js-json-post" type="submit" href="login.json" result="location.href='index.html'" id="login-button">登录</button>
		</form>
	</div>
	<!--背景动态效果-->
	<ul class="bg-bubbles">
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
	</ul><!--./背景动态效果-->
	
</div>
<script type="text/javascript" src="@res("/static/js/jquery/jquery-1.8.3.js")"></script>
</body>
<script>
// 	$("#regist-button").click(function(){
// 		$("#loginform").attr("action","login.html?type=1").submit();
// 	});
	//使用ajax提交a标签所在部分的表单
    $(".js-json-post").click(function () {
        var that=this;
        var url=$(this).attr("href");
        var data=$("input,:checkbox:checked",$(this).closest(".js-partial-form"));
        $.post(url,data,function(r){
        	if(r.result){
	        	if(r.data.code!=0){
	        		alert(r.data.msg);
	        	}else{
	        		eval($(that).attr("result")||"{}");
	        	}
        	}else{
        		alert(r.data);
        	}
        });
        return false;
      });
</script>
</html>